package com.sloth.bear.controller;

import com.sloth.bear.dto.request.CollectListRequest;
import com.sloth.bear.dto.request.CreateCollectRequest;
import com.sloth.bear.dto.vo.CollectListVo;
import com.sloth.bear.service.CollectService;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/collect")
@RequiredArgsConstructor
public class CollectController {

    private final CollectService collectService;

    /**
     * 创建收藏
     */
    @PostMapping("/create")
    public Long createCollect(@Valid @RequestBody CreateCollectRequest request) {
        return collectService.createCollect(request);
    }

    /**
     * 收藏列表
     */
    @GetMapping("/list")
    public List<CollectListVo> listCollect(CollectListRequest request) {
        return collectService.listCollect(request);
    }

    /**
     * 收藏详情
     */
    @GetMapping("/{id}")
    public CollectListVo detailsCollect(@PathVariable Long id) {
        return collectService.detailsCollect(id);
    }

    /**
     * 更新收藏
     */
    @PutMapping("/{id}")
    public void updateCollect(@PathVariable Long id, @Valid @RequestBody CreateCollectRequest request) {
        collectService.updateCollect(id, request);
    }

    /**
     * 删除收藏项
     */
    @DeleteMapping("/{id}")
    public void deleteCollect(@PathVariable Long id) {
        collectService.deleteCollect(id);
    }
}